

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>scitools.sound &mdash; SciTools 0.9.0 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.9.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="top" title="SciTools 0.9.0 documentation" href="../../index.html" />
    <link rel="up" title="Module code" href="../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../../np-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">SciTools 0.9.0 documentation</a> &raquo;</li>
          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for scitools.sound</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">math</span><span class="o">,</span> <span class="nn">numpy</span><span class="o">,</span> <span class="nn">wave</span><span class="o">,</span> <span class="nn">commands</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">os</span>

<span class="n">max_amplitude</span> <span class="o">=</span> <span class="mi">2</span><span class="o">**</span><span class="mi">15</span><span class="o">-</span><span class="mi">1</span> <span class="c"># iinfo(&#39;int16&#39;).max if numpy &gt;= 1.0.3</span>

<div class="viewcode-block" id="write"><a class="viewcode-back" href="../../sound.html#scitools.sound.write">[docs]</a><span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">channels</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">sample_width</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">44100</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Writes the array data to the specified file.</span>
<span class="sd">    The array data type can be arbitrary as it will be</span>
<span class="sd">    converted to numpy.int16 in this function.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ofile</span> <span class="o">=</span> <span class="n">wave</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s">&#39;w&#39;</span><span class="p">)</span>
    <span class="n">ofile</span><span class="o">.</span><span class="n">setnchannels</span><span class="p">(</span><span class="n">channels</span><span class="p">)</span>
    <span class="n">ofile</span><span class="o">.</span><span class="n">setsampwidth</span><span class="p">(</span><span class="n">sample_width</span><span class="p">)</span>
    <span class="n">ofile</span><span class="o">.</span><span class="n">setframerate</span><span class="p">(</span><span class="n">sample_rate</span><span class="p">)</span>
    <span class="n">ofile</span><span class="o">.</span><span class="n">writeframesraw</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">int16</span><span class="p">)</span><span class="o">.</span><span class="n">tostring</span><span class="p">())</span>
    <span class="n">ofile</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="read"><a class="viewcode-back" href="../../sound.html#scitools.sound.read">[docs]</a><span class="k">def</span> <span class="nf">read</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Read sound data in a file and return the data as an array</span>
<span class="sd">    with data type numpy.int16.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ifile</span> <span class="o">=</span> <span class="n">wave</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
    <span class="n">channels</span> <span class="o">=</span> <span class="n">ifile</span><span class="o">.</span><span class="n">getnchannels</span><span class="p">()</span>
    <span class="n">sample_width</span> <span class="o">=</span> <span class="n">ifile</span><span class="o">.</span><span class="n">getsampwidth</span><span class="p">()</span>
    <span class="n">sample_rate</span> <span class="o">=</span> <span class="n">ifile</span><span class="o">.</span><span class="n">getframerate</span><span class="p">()</span>
    <span class="n">frames</span> <span class="o">=</span> <span class="n">ifile</span><span class="o">.</span><span class="n">getnframes</span><span class="p">()</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">ifile</span><span class="o">.</span><span class="n">readframes</span><span class="p">(</span><span class="n">frames</span><span class="p">)</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">fromstring</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">numpy</span><span class="o">.</span><span class="n">uint16</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">data</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">int16</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="play"><a class="viewcode-back" href="../../sound.html#scitools.sound.play">[docs]</a><span class="k">def</span> <span class="nf">play</span><span class="p">(</span><span class="n">soundfile</span><span class="p">,</span> <span class="n">player</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Play a file with name soundfile or an array soundfile.</span>
<span class="sd">    (The array is first written to file using the write function</span>
<span class="sd">    so the data type can be arbitrary.)</span>
<span class="sd">    The player is chosen by the programs &#39;open&#39; on Mac and &#39;start&#39;</span>
<span class="sd">    on Windows. On Linux, try different open programs for various</span>
<span class="sd">    distributions. If keyword argument &#39;player&#39; is given, only this spesific</span>
<span class="sd">    commands is run.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">tmpfile</span> <span class="o">=</span> <span class="s">&#39;tmp.wav&#39;</span>
    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">soundfile</span><span class="p">,</span> <span class="n">numpy</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
        <span class="n">write</span><span class="p">(</span><span class="n">soundfile</span><span class="p">,</span> <span class="n">tmpfile</span><span class="p">)</span>
    <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">soundfile</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
        <span class="n">tmpfile</span> <span class="o">=</span> <span class="n">soundfile</span>

    <span class="k">if</span> <span class="n">player</span><span class="p">:</span>
        <span class="n">msg</span> <span class="o">=</span> <span class="s">&#39;Unable to open sound file with </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="n">player</span>
        <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span><span class="p">[:</span><span class="mi">3</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;win&#39;</span><span class="p">:</span>
            <span class="n">status</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="p">(</span><span class="n">player</span><span class="p">,</span> <span class="n">tmpfile</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">status</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">commands</span><span class="o">.</span><span class="n">getstatusoutput</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="p">(</span><span class="n">player</span><span class="p">,</span> <span class="n">tmpfile</span><span class="p">))</span>
            <span class="n">msg</span> <span class="o">+=</span> <span class="s">&#39;</span><span class="se">\n</span><span class="s">Error message:</span><span class="se">\n</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="n">output</span>
        <span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">OSError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
        <span class="k">return</span>

    <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span><span class="p">[:</span><span class="mi">5</span><span class="p">]</span> <span class="o">==</span> <span class="s">&#39;linux&#39;</span><span class="p">:</span>
        <span class="n">open_commands</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;gnome-open&#39;</span><span class="p">,</span> <span class="s">&#39;kmfclient exec&#39;</span><span class="p">,</span> <span class="s">&#39;exo-open&#39;</span><span class="p">,</span> <span class="s">&#39;xdg-open&#39;</span><span class="p">,</span> <span class="s">&#39;open&#39;</span><span class="p">]</span>
        <span class="k">for</span> <span class="n">cmd</span> <span class="ow">in</span> <span class="n">open_commands</span><span class="p">:</span>
            <span class="n">status</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">commands</span><span class="o">.</span><span class="n">getstatusoutput</span><span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">tmpfile</span><span class="p">))</span>
            <span class="k">if</span> <span class="n">status</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">break</span>
        <span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">OSError</span><span class="p">(</span><span class="s">&#39;Unable to open sound file, try to set player&#39;</span>\
                              <span class="s">&#39; keyword argument.&#39;</span><span class="p">)</span>

    <span class="k">elif</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span> <span class="o">==</span> <span class="s">&#39;darwin&#39;</span><span class="p">:</span>
        <span class="n">commands</span><span class="o">.</span><span class="n">getstatusoutput</span><span class="p">(</span><span class="s">&#39;open </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="n">tmpfile</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="c"># assume windows</span>
        <span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s">&#39;start </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span><span class="n">tmpfile</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="note"><a class="viewcode-back" href="../../sound.html#scitools.sound.note">[docs]</a><span class="k">def</span> <span class="nf">note</span><span class="p">(</span><span class="n">frequency</span><span class="p">,</span> <span class="n">length</span><span class="p">,</span> <span class="n">amplitude</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">44100</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Generate the sound of a note as an array if float elements.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">time_points</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">length</span><span class="p">,</span> <span class="n">length</span><span class="o">*</span><span class="n">sample_rate</span><span class="p">)</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">numpy</span><span class="o">.</span><span class="n">pi</span><span class="o">*</span><span class="n">frequency</span><span class="o">*</span><span class="n">time_points</span><span class="p">)</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">amplitude</span><span class="o">*</span><span class="n">data</span>
    <span class="k">return</span> <span class="n">data</span>
</div>
<div class="viewcode-block" id="add_echo"><a class="viewcode-back" href="../../sound.html#scitools.sound.add_echo">[docs]</a><span class="k">def</span> <span class="nf">add_echo</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">beta</span><span class="o">=</span><span class="mf">0.8</span><span class="p">,</span> <span class="n">delay</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">sample_rate</span><span class="o">=</span><span class="mi">44100</span><span class="p">):</span>
    <span class="n">newdata</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
    <span class="n">shift</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">delay</span><span class="o">*</span><span class="n">sample_rate</span><span class="p">)</span>  <span class="c"># b (math symbol)</span>
    <span class="n">newdata</span><span class="p">[</span><span class="n">shift</span><span class="p">:]</span> <span class="o">=</span> <span class="n">beta</span><span class="o">*</span><span class="n">data</span><span class="p">[</span><span class="n">shift</span><span class="p">:]</span> <span class="o">+</span> \
                      <span class="p">(</span><span class="mi">1</span><span class="o">-</span><span class="n">beta</span><span class="p">)</span><span class="o">*</span><span class="n">data</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">-</span><span class="n">shift</span><span class="p">]</span>
    <span class="c">#for i in xrange(shift, len(data)):</span>
    <span class="c">#    newdata[i] = beta*data[i] + (1-beta)*data[i-shift]</span>
    <span class="k">return</span> <span class="n">newdata</span>
</div>
<span class="k">def</span> <span class="nf">_test1</span><span class="p">():</span>
    <span class="n">filename</span> <span class="o">=</span> <span class="s">&#39;tmp.wav&#39;</span>

    <span class="n">tone1</span> <span class="o">=</span> <span class="n">max_amplitude</span><span class="o">*</span><span class="n">note</span><span class="p">(</span><span class="mi">440</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">)</span>
    <span class="n">tone2</span> <span class="o">=</span> <span class="n">max_amplitude</span><span class="o">*</span><span class="n">note</span><span class="p">(</span><span class="mf">293.66</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
    <span class="n">tone3</span> <span class="o">=</span> <span class="n">max_amplitude</span><span class="o">*</span><span class="n">note</span><span class="p">(</span><span class="mi">440</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">0.8</span><span class="p">)</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">concatenate</span><span class="p">((</span><span class="n">tone1</span><span class="p">,</span> <span class="n">tone2</span><span class="p">,</span> <span class="n">tone3</span><span class="p">))</span>
    <span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">filename</span><span class="p">)</span>
    <span class="n">data</span> <span class="o">=</span> <span class="n">read</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
    <span class="n">play</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>

<div class="viewcode-block" id="Nothing_Else_Matters"><a class="viewcode-back" href="../../sound.html#scitools.sound.Nothing_Else_Matters">[docs]</a><span class="k">def</span> <span class="nf">Nothing_Else_Matters</span><span class="p">(</span><span class="n">echo</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
    <span class="n">E1</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">164.81</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">G</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mi">392</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">B</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">493.88</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">E2</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">659.26</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">intro</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">concatenate</span><span class="p">((</span><span class="n">E1</span><span class="p">,</span> <span class="n">G</span><span class="p">,</span> <span class="n">B</span><span class="p">,</span> <span class="n">E2</span><span class="p">,</span> <span class="n">B</span><span class="p">,</span> <span class="n">G</span><span class="p">))</span>
    <span class="n">high1_long</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">987.77</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
    <span class="n">high1_short</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">987.77</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">high2</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">1046.50</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">high3</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mi">880</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">high4_long</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">659.26</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
    <span class="n">high4_medium</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">659.26</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">high4_short</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">659.26</span><span class="p">,</span> <span class="o">.</span><span class="mi">25</span><span class="p">)</span>
    <span class="n">high5</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mf">739.99</span><span class="p">,</span> <span class="o">.</span><span class="mi">25</span><span class="p">)</span>
    <span class="n">pause_long</span> <span class="o">=</span>  <span class="n">note</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">)</span>
    <span class="n">pause_short</span> <span class="o">=</span> <span class="n">note</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">.</span><span class="mi">25</span><span class="p">)</span>
    <span class="n">song</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">concatenate</span><span class="p">(</span>
      <span class="p">(</span><span class="n">intro</span><span class="p">,</span> <span class="n">intro</span><span class="p">,</span> <span class="n">high1_long</span><span class="p">,</span> <span class="n">pause_long</span><span class="p">,</span> <span class="n">high1_long</span><span class="p">,</span>
       <span class="n">pause_long</span><span class="p">,</span> <span class="n">pause_long</span><span class="p">,</span>
       <span class="n">high1_short</span><span class="p">,</span> <span class="n">high2</span><span class="p">,</span> <span class="n">high1_short</span><span class="p">,</span> <span class="n">high3</span><span class="p">,</span> <span class="n">high1_short</span><span class="p">,</span>
       <span class="n">high3</span><span class="p">,</span> <span class="n">high4_short</span><span class="p">,</span> <span class="n">pause_short</span><span class="p">,</span> <span class="n">high4_long</span><span class="p">,</span> <span class="n">pause_short</span><span class="p">,</span>
       <span class="n">high4_medium</span><span class="p">,</span> <span class="n">high5</span><span class="p">,</span> <span class="n">high4_short</span><span class="p">))</span>
    <span class="n">song</span> <span class="o">*=</span> <span class="n">max_amplitude</span>
    <span class="k">if</span> <span class="n">echo</span><span class="p">:</span>
        <span class="n">song</span> <span class="o">=</span> <span class="n">add_echo</span><span class="p">(</span><span class="n">song</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">song</span>

<span class="c"># equal-tempered scale:</span></div>
<span class="n">note2freq</span> <span class="o">=</span> <span class="p">{</span>
 <span class="s">&#39;A#0&#39;</span><span class="p">:</span> <span class="mf">29.14</span><span class="p">,</span>
 <span class="s">&#39;A#1&#39;</span><span class="p">:</span> <span class="mf">58.27</span><span class="p">,</span>
 <span class="s">&#39;A#2&#39;</span><span class="p">:</span> <span class="mf">116.54</span><span class="p">,</span>
 <span class="s">&#39;A#3&#39;</span><span class="p">:</span> <span class="mf">233.08</span><span class="p">,</span>
 <span class="s">&#39;A#4&#39;</span><span class="p">:</span> <span class="mf">466.16</span><span class="p">,</span>
 <span class="s">&#39;A#5&#39;</span><span class="p">:</span> <span class="mf">932.33</span><span class="p">,</span>
 <span class="s">&#39;A#6&#39;</span><span class="p">:</span> <span class="mf">1864.66</span><span class="p">,</span>
 <span class="s">&#39;A#7&#39;</span><span class="p">:</span> <span class="mf">3729.31</span><span class="p">,</span>
 <span class="s">&#39;A0&#39;</span><span class="p">:</span> <span class="mf">27.5</span><span class="p">,</span>
 <span class="s">&#39;A1&#39;</span><span class="p">:</span> <span class="mi">55</span><span class="p">,</span>
 <span class="s">&#39;A2&#39;</span><span class="p">:</span> <span class="mi">110</span><span class="p">,</span>
 <span class="s">&#39;A3&#39;</span><span class="p">:</span> <span class="mi">220</span><span class="p">,</span>
 <span class="s">&#39;A4&#39;</span><span class="p">:</span> <span class="mi">440</span><span class="p">,</span>
 <span class="s">&#39;A5&#39;</span><span class="p">:</span> <span class="mi">880</span><span class="p">,</span>
 <span class="s">&#39;A6&#39;</span><span class="p">:</span> <span class="mi">1760</span><span class="p">,</span>
 <span class="s">&#39;A7&#39;</span><span class="p">:</span> <span class="mi">3520</span><span class="p">,</span>
 <span class="s">&#39;Ab0&#39;</span><span class="p">:</span> <span class="mf">25.96</span><span class="p">,</span>
 <span class="s">&#39;Ab1&#39;</span><span class="p">:</span> <span class="mf">51.91</span><span class="p">,</span>
 <span class="s">&#39;Ab2&#39;</span><span class="p">:</span> <span class="mf">103.83</span><span class="p">,</span>
 <span class="s">&#39;Ab3&#39;</span><span class="p">:</span> <span class="mf">207.65</span><span class="p">,</span>
 <span class="s">&#39;Ab4&#39;</span><span class="p">:</span> <span class="mf">415.3</span><span class="p">,</span>
 <span class="s">&#39;Ab5&#39;</span><span class="p">:</span> <span class="mf">830.61</span><span class="p">,</span>
 <span class="s">&#39;Ab6&#39;</span><span class="p">:</span> <span class="mf">1661.22</span><span class="p">,</span>
 <span class="s">&#39;Ab7&#39;</span><span class="p">:</span> <span class="mf">3322.44</span><span class="p">,</span>
 <span class="s">&#39;B0&#39;</span><span class="p">:</span> <span class="mf">30.87</span><span class="p">,</span>
 <span class="s">&#39;B1&#39;</span><span class="p">:</span> <span class="mf">61.74</span><span class="p">,</span>
 <span class="s">&#39;B2&#39;</span><span class="p">:</span> <span class="mf">123.47</span><span class="p">,</span>
 <span class="s">&#39;B3&#39;</span><span class="p">:</span> <span class="mf">246.94</span><span class="p">,</span>
 <span class="s">&#39;B4&#39;</span><span class="p">:</span> <span class="mf">493.88</span><span class="p">,</span>
 <span class="s">&#39;B5&#39;</span><span class="p">:</span> <span class="mf">987.77</span><span class="p">,</span>
 <span class="s">&#39;B6&#39;</span><span class="p">:</span> <span class="mf">1975.53</span><span class="p">,</span>
 <span class="s">&#39;B7&#39;</span><span class="p">:</span> <span class="mf">3951.07</span><span class="p">,</span>
 <span class="s">&#39;Bb0&#39;</span><span class="p">:</span> <span class="mf">29.14</span><span class="p">,</span>
 <span class="s">&#39;Bb1&#39;</span><span class="p">:</span> <span class="mf">58.27</span><span class="p">,</span>
 <span class="s">&#39;Bb2&#39;</span><span class="p">:</span> <span class="mf">116.54</span><span class="p">,</span>
 <span class="s">&#39;Bb3&#39;</span><span class="p">:</span> <span class="mf">233.08</span><span class="p">,</span>
 <span class="s">&#39;Bb4&#39;</span><span class="p">:</span> <span class="mf">466.16</span><span class="p">,</span>
 <span class="s">&#39;Bb5&#39;</span><span class="p">:</span> <span class="mf">932.33</span><span class="p">,</span>
 <span class="s">&#39;Bb6&#39;</span><span class="p">:</span> <span class="mf">1864.66</span><span class="p">,</span>
 <span class="s">&#39;Bb7&#39;</span><span class="p">:</span> <span class="mf">3729.31</span><span class="p">,</span>
 <span class="s">&#39;C#0&#39;</span><span class="p">:</span> <span class="mf">17.32</span><span class="p">,</span>
 <span class="s">&#39;C#1&#39;</span><span class="p">:</span> <span class="mf">34.65</span><span class="p">,</span>
 <span class="s">&#39;C#2&#39;</span><span class="p">:</span> <span class="mf">69.3</span><span class="p">,</span>
 <span class="s">&#39;C#3&#39;</span><span class="p">:</span> <span class="mf">138.59</span><span class="p">,</span>
 <span class="s">&#39;C#4&#39;</span><span class="p">:</span> <span class="mf">277.18</span><span class="p">,</span>
 <span class="s">&#39;C#5&#39;</span><span class="p">:</span> <span class="mf">554.37</span><span class="p">,</span>
 <span class="s">&#39;C#6&#39;</span><span class="p">:</span> <span class="mf">1108.73</span><span class="p">,</span>
 <span class="s">&#39;C#7&#39;</span><span class="p">:</span> <span class="mf">2217.46</span><span class="p">,</span>
 <span class="s">&#39;C#8&#39;</span><span class="p">:</span> <span class="mf">4434.92</span><span class="p">,</span>
 <span class="s">&#39;C1&#39;</span><span class="p">:</span> <span class="mf">32.7</span><span class="p">,</span>
 <span class="s">&#39;C2&#39;</span><span class="p">:</span> <span class="mf">65.41</span><span class="p">,</span>
 <span class="s">&#39;C3&#39;</span><span class="p">:</span> <span class="mf">130.81</span><span class="p">,</span>
 <span class="s">&#39;C4&#39;</span><span class="p">:</span> <span class="mf">261.63</span><span class="p">,</span>
 <span class="s">&#39;C5&#39;</span><span class="p">:</span> <span class="mf">523.25</span><span class="p">,</span>
 <span class="s">&#39;C6&#39;</span><span class="p">:</span> <span class="mf">1046.5</span><span class="p">,</span>
 <span class="s">&#39;C7&#39;</span><span class="p">:</span> <span class="mi">2093</span><span class="p">,</span>
 <span class="s">&#39;C8&#39;</span><span class="p">:</span> <span class="mf">4186.01</span><span class="p">,</span>
 <span class="s">&#39;D#0&#39;</span><span class="p">:</span> <span class="mf">19.45</span><span class="p">,</span>
 <span class="s">&#39;D#1&#39;</span><span class="p">:</span> <span class="mf">38.89</span><span class="p">,</span>
 <span class="s">&#39;D#2&#39;</span><span class="p">:</span> <span class="mf">77.78</span><span class="p">,</span>
 <span class="s">&#39;D#3&#39;</span><span class="p">:</span> <span class="mf">155.56</span><span class="p">,</span>
 <span class="s">&#39;D#4&#39;</span><span class="p">:</span> <span class="mf">311.13</span><span class="p">,</span>
 <span class="s">&#39;D#5&#39;</span><span class="p">:</span> <span class="mf">622.25</span><span class="p">,</span>
 <span class="s">&#39;D#6&#39;</span><span class="p">:</span> <span class="mf">1244.51</span><span class="p">,</span>
 <span class="s">&#39;D#7&#39;</span><span class="p">:</span> <span class="mf">2489.02</span><span class="p">,</span>
 <span class="s">&#39;D#8&#39;</span><span class="p">:</span> <span class="mf">4978.03</span><span class="p">,</span>
 <span class="s">&#39;D0&#39;</span><span class="p">:</span> <span class="mf">18.35</span><span class="p">,</span>
 <span class="s">&#39;D1&#39;</span><span class="p">:</span> <span class="mf">36.71</span><span class="p">,</span>
 <span class="s">&#39;D2&#39;</span><span class="p">:</span> <span class="mf">73.42</span><span class="p">,</span>
 <span class="s">&#39;D3&#39;</span><span class="p">:</span> <span class="mf">146.83</span><span class="p">,</span>
 <span class="s">&#39;D4&#39;</span><span class="p">:</span> <span class="mf">293.66</span><span class="p">,</span>
 <span class="s">&#39;D5&#39;</span><span class="p">:</span> <span class="mf">587.33</span><span class="p">,</span>
 <span class="s">&#39;D6&#39;</span><span class="p">:</span> <span class="mf">1174.66</span><span class="p">,</span>
 <span class="s">&#39;D7&#39;</span><span class="p">:</span> <span class="mf">2349.32</span><span class="p">,</span>
 <span class="s">&#39;D8&#39;</span><span class="p">:</span> <span class="mf">4698.64</span><span class="p">,</span>
 <span class="s">&#39;Db0&#39;</span><span class="p">:</span> <span class="mf">17.32</span><span class="p">,</span>
 <span class="s">&#39;Db1&#39;</span><span class="p">:</span> <span class="mf">34.65</span><span class="p">,</span>
 <span class="s">&#39;Db2&#39;</span><span class="p">:</span> <span class="mf">69.3</span><span class="p">,</span>
 <span class="s">&#39;Db3&#39;</span><span class="p">:</span> <span class="mf">138.59</span><span class="p">,</span>
 <span class="s">&#39;Db4&#39;</span><span class="p">:</span> <span class="mf">277.18</span><span class="p">,</span>
 <span class="s">&#39;Db5&#39;</span><span class="p">:</span> <span class="mf">554.37</span><span class="p">,</span>
 <span class="s">&#39;Db6&#39;</span><span class="p">:</span> <span class="mf">1108.73</span><span class="p">,</span>
 <span class="s">&#39;Db7&#39;</span><span class="p">:</span> <span class="mf">2217.46</span><span class="p">,</span>
 <span class="s">&#39;Db8&#39;</span><span class="p">:</span> <span class="mf">4434.92</span><span class="p">,</span>
 <span class="s">&#39;E0&#39;</span><span class="p">:</span> <span class="mf">20.6</span><span class="p">,</span>
 <span class="s">&#39;E1&#39;</span><span class="p">:</span> <span class="mf">41.2</span><span class="p">,</span>
 <span class="s">&#39;E2&#39;</span><span class="p">:</span> <span class="mf">82.41</span><span class="p">,</span>
 <span class="s">&#39;E3&#39;</span><span class="p">:</span> <span class="mf">164.81</span><span class="p">,</span>
 <span class="s">&#39;E4&#39;</span><span class="p">:</span> <span class="mf">329.63</span><span class="p">,</span>
 <span class="s">&#39;E5&#39;</span><span class="p">:</span> <span class="mf">659.26</span><span class="p">,</span>
 <span class="s">&#39;E6&#39;</span><span class="p">:</span> <span class="mf">1318.51</span><span class="p">,</span>
 <span class="s">&#39;E7&#39;</span><span class="p">:</span> <span class="mf">2637.02</span><span class="p">,</span>
 <span class="s">&#39;Eb0&#39;</span><span class="p">:</span> <span class="mf">19.45</span><span class="p">,</span>
 <span class="s">&#39;Eb1&#39;</span><span class="p">:</span> <span class="mf">38.89</span><span class="p">,</span>
 <span class="s">&#39;Eb2&#39;</span><span class="p">:</span> <span class="mf">77.78</span><span class="p">,</span>
 <span class="s">&#39;Eb3&#39;</span><span class="p">:</span> <span class="mf">155.56</span><span class="p">,</span>
 <span class="s">&#39;Eb4&#39;</span><span class="p">:</span> <span class="mf">311.13</span><span class="p">,</span>
 <span class="s">&#39;Eb5&#39;</span><span class="p">:</span> <span class="mf">622.25</span><span class="p">,</span>
 <span class="s">&#39;Eb6&#39;</span><span class="p">:</span> <span class="mf">1244.51</span><span class="p">,</span>
 <span class="s">&#39;Eb7&#39;</span><span class="p">:</span> <span class="mf">2489.02</span><span class="p">,</span>
 <span class="s">&#39;Eb8&#39;</span><span class="p">:</span> <span class="mf">4978.03</span><span class="p">,</span>
 <span class="s">&#39;F#0&#39;</span><span class="p">:</span> <span class="mf">23.12</span><span class="p">,</span>
 <span class="s">&#39;F#1&#39;</span><span class="p">:</span> <span class="mf">46.25</span><span class="p">,</span>
 <span class="s">&#39;F#2&#39;</span><span class="p">:</span> <span class="mf">92.5</span><span class="p">,</span>
 <span class="s">&#39;F#3&#39;</span><span class="p">:</span> <span class="mi">185</span><span class="p">,</span>
 <span class="s">&#39;F#4&#39;</span><span class="p">:</span> <span class="mf">369.99</span><span class="p">,</span>
 <span class="s">&#39;F#5&#39;</span><span class="p">:</span> <span class="mf">739.99</span><span class="p">,</span>
 <span class="s">&#39;F#6&#39;</span><span class="p">:</span> <span class="mf">1479.98</span><span class="p">,</span>
 <span class="s">&#39;F#7&#39;</span><span class="p">:</span> <span class="mf">2959.96</span><span class="p">,</span>
 <span class="s">&#39;F0&#39;</span><span class="p">:</span> <span class="mf">21.83</span><span class="p">,</span>
 <span class="s">&#39;F1&#39;</span><span class="p">:</span> <span class="mf">43.65</span><span class="p">,</span>
 <span class="s">&#39;F2&#39;</span><span class="p">:</span> <span class="mf">87.31</span><span class="p">,</span>
 <span class="s">&#39;F3&#39;</span><span class="p">:</span> <span class="mf">174.61</span><span class="p">,</span>
 <span class="s">&#39;F4&#39;</span><span class="p">:</span> <span class="mf">349.23</span><span class="p">,</span>
 <span class="s">&#39;F5&#39;</span><span class="p">:</span> <span class="mf">698.46</span><span class="p">,</span>
 <span class="s">&#39;F6&#39;</span><span class="p">:</span> <span class="mf">1396.91</span><span class="p">,</span>
 <span class="s">&#39;F7&#39;</span><span class="p">:</span> <span class="mf">2793.83</span><span class="p">,</span>
 <span class="s">&#39;G#0&#39;</span><span class="p">:</span> <span class="mf">25.96</span><span class="p">,</span>
 <span class="s">&#39;G#1&#39;</span><span class="p">:</span> <span class="mf">51.91</span><span class="p">,</span>
 <span class="s">&#39;G#2&#39;</span><span class="p">:</span> <span class="mf">103.83</span><span class="p">,</span>
 <span class="s">&#39;G#3&#39;</span><span class="p">:</span> <span class="mf">207.65</span><span class="p">,</span>
 <span class="s">&#39;G#4&#39;</span><span class="p">:</span> <span class="mf">415.3</span><span class="p">,</span>
 <span class="s">&#39;G#5&#39;</span><span class="p">:</span> <span class="mf">830.61</span><span class="p">,</span>
 <span class="s">&#39;G#6&#39;</span><span class="p">:</span> <span class="mf">1661.22</span><span class="p">,</span>
 <span class="s">&#39;G#7&#39;</span><span class="p">:</span> <span class="mf">3322.44</span><span class="p">,</span>
 <span class="s">&#39;G0&#39;</span><span class="p">:</span> <span class="mf">24.5</span><span class="p">,</span>
 <span class="s">&#39;G1&#39;</span><span class="p">:</span> <span class="mi">49</span><span class="p">,</span>
 <span class="s">&#39;G2&#39;</span><span class="p">:</span> <span class="mi">98</span><span class="p">,</span>
 <span class="s">&#39;G3&#39;</span><span class="p">:</span> <span class="mi">196</span><span class="p">,</span>
 <span class="s">&#39;G4&#39;</span><span class="p">:</span> <span class="mi">392</span><span class="p">,</span>
 <span class="s">&#39;G5&#39;</span><span class="p">:</span> <span class="mf">783.99</span><span class="p">,</span>
 <span class="s">&#39;G6&#39;</span><span class="p">:</span> <span class="mf">1567.98</span><span class="p">,</span>
 <span class="s">&#39;G7&#39;</span><span class="p">:</span> <span class="mf">3135.96</span><span class="p">,</span>
 <span class="s">&#39;Gb0&#39;</span><span class="p">:</span> <span class="mf">23.12</span><span class="p">,</span>
 <span class="s">&#39;Gb1&#39;</span><span class="p">:</span> <span class="mf">46.25</span><span class="p">,</span>
 <span class="s">&#39;Gb2&#39;</span><span class="p">:</span> <span class="mf">92.5</span><span class="p">,</span>
 <span class="s">&#39;Gb3&#39;</span><span class="p">:</span> <span class="mi">185</span><span class="p">,</span>
 <span class="s">&#39;Gb4&#39;</span><span class="p">:</span> <span class="mf">369.99</span><span class="p">,</span>
 <span class="s">&#39;Gb5&#39;</span><span class="p">:</span> <span class="mf">739.99</span><span class="p">,</span>
 <span class="s">&#39;Gb6&#39;</span><span class="p">:</span> <span class="mf">1479.98</span><span class="p">,</span>
 <span class="s">&#39;Gb7&#39;</span><span class="p">:</span> <span class="mf">2959.96</span><span class="p">}</span>
    
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="c">#_test1()</span>
    <span class="n">song</span> <span class="o">=</span> <span class="n">Nothing_Else_Matters</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
    <span class="n">play</span><span class="p">(</span><span class="n">song</span><span class="p">)</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/scitools_logo.jpg" alt="Logo"/>
            </a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../../np-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">SciTools 0.9.0 documentation</a> &raquo;</li>
          <li><a href="../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, H. P. Langtangen, J. Ring, ++.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>